//
// Created by wyh on 2025-06-16 19:28.
//

#ifndef TEST_UTILITY_SINGLETON_H
#define TEST_UTILITY_SINGLETON_H

namespace wyh {
    namespace utility {
        template <typename T>
        class Singleton
                {
        public:
            static T* instance()
            {
                static T instance;
                return &instance;
            }

        private:
            Singleton()=default;
            Singleton(const Singleton<T> &) = delete;
            Singleton<T> &operator=(const Singleton<T> &) = delete;
            ~Singleton() = default;
        };


#define SINGLETON(classname)\
        friend class Singleton<classname>;\
        private:\
        classname()=default;\
        classname(const classname &) = delete;\
        classname &operator=(const classname &) = delete;\
        ~classname() = default\

    } // namespace utility
} // namespace wyh

#endif //TEST_UTILITY_SINGLETON_H
